//
//  BaseTableViewController.swift
//  SinaWeibo
//
//  Created by 石林 on 15/11/11.
//  Copyright © 2015年 石林. All rights reserved.
//

import UIKit

class BaseTableViewController: UITableViewController,VisitorLoginViewDelegate {

    //添加用户是否登录标记
//    var userLogin = UserAccount.loadAccount() != nil
    var userLogin = false//UserAccountViewModel().userLogin
    
    var visitorLoginView: VisitorLoginView?
    
    override func loadView() {
        userLogin ? super.loadView() : loadVisitorView()
    }
    
    func loadVisitorView() {
        visitorLoginView = VisitorLoginView()
        visitorLoginView?.visitorDelegate = self
        view = visitorLoginView
        
        self.navigationItem.leftBarButtonItem = UIBarButtonItem(title: "登录", style: .Plain, target: self, action: "visitorWillLogin")
        self.navigationItem.rightBarButtonItem = UIBarButtonItem(title: "注册", style: .Plain, target: self, action: "visitorWillRegistor")
    }
    
    func visitorWillLogin() {
        print("login")
        let oauth = OAuthViewController()
        let nav = UINavigationController(rootViewController: oauth)
        presentViewController(nav, animated: true, completion: nil)
    }
    
    func visitorWillRegistor() {
        print("registor")
    }
    
    override func viewDidLoad() {
        super.viewDidLoad()
        
    }

}
